package edu.chl.da.hotelbooking;

import java.util.List;
import javax.xml.bind.annotation.*;

/**
 * Respresent a hotel suggestion
 * @author Jakob
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "HotelSuggestionType", propOrder = {
    "name",
    "destination",
    "fromDate",
    "toDate",
    "description",
    "price",
    "pictureUrl",
    "links"

})
public class HotelSuggestion {

    @XmlElement(required = false)
    private String name;
    @XmlElement(required = true)
    private String destination;
    @XmlElement(required = true)
    private String fromDate;
    @XmlElement(required = true)
    private String toDate;
    @XmlElement(required = false)
    private String description;
    @XmlElement(required = false)
    private double price;
    @XmlElement(required = false)
    private String pictureUrl;
    @XmlElementRef
    protected List<Link> links;

    public HotelSuggestion() {
    }

    public HotelSuggestion(String destination, String fromDate, String toDate) {
        this.destination = destination;
        this.fromDate = fromDate;
        this.toDate = toDate;
    }

    public HotelSuggestion(String name, String description, double price, String pictureUrl) {
        this.name = name;
        this.description = description;
        this.price = price;
        this.pictureUrl = pictureUrl;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDestination() {
        return destination;
    }

    public void setDestination(String destination) {
        this.destination = destination;
    }

    public String getFromDate() {
        return fromDate;
    }

    public void setFromDate(String fromDate) {
        this.fromDate = fromDate;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPictureUrl() {
        return pictureUrl;
    }

    public void setPictureUrl(String pictureUrl) {
        this.pictureUrl = pictureUrl;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getToDate() {
        return toDate;
    }

    public void setToDate(String toDate) {
        this.toDate = toDate;
    }



   
   public List<Link> getLinks(){
      return links;
   }

   public void setLinks(List<Link> links){
      this.links = links;
   }

   @XmlTransient
   public String getNext(){
      if (links == null) return null;
      for (Link link : links)
      {
         if ("next".equals(link.getRelationship())) return link.getHref();
      }
      return null;
   }

   @XmlTransient
   public String getPrevious(){
      if (links == null) return null;
      for (Link link : links)
      {
         if ("previous".equals(link.getRelationship())) return link.getHref();
      }
      return null;
   }

}
